type matrix = int list list;;

let print_int_list = List.iter (Printf.printf "%d, ");;
let print_int_list_list = List.iter (fun l -> (List.iter (Printf.printf "%d, ") l); print_newline ());;

let map f = List.map (List.map f)

let line_trans = List.map (fun x -> [x]);;

let line_append a b =
    List.map2 List.append a b;;

let line_trans_then_append l0 need_trans = need_trans |> line_trans |> line_append l0;;

let matrix_trans mat =
    List.fold_left
    line_trans_then_append
    (List.init (List.length mat) (fun _ -> []))
    mat;;

let matrix0 = [[1; 2; 3]; [4; 5; 6]; [7; 8; 9]];;

let line = [1; 2; 3];;
let line_2d = [[1]; [2]; [3]];;

let _ = map ((+) 1) matrix0;;

let _ = line_trans line;;
let _ = line_append line_2d line_2d;;
let _ = line_trans_then_append line_2d line;;

let _ = line_trans_then_append (List.init 3 (fun _ -> [])) [4; 2; 3];;

let _ = matrix_trans matrix0;;
